<?php
/**
 * Created by 784855684@qq.com.
 * Link: https://github.com/lichtung/wshore
 * User: linzh
 * Date: 7/10/17
 * Time: 7:26 PM
 */
declare(strict_types=1);


namespace application\module\admin\library\component;


use application\module\admin\addon\Sign;
use application\module\admin\library\Component;

/**
 * Class UserPanel 用户面板
 * @package application\module\admin\library\component
 */
class UserPanel extends Component
{

    public function __toString()
    {
        $user = Sign::getInstance()->getUser();
        $avatar = $user->avatar;
        if (strpos($avatar, 'data:image/') !== 0) {
            $avatar = WS_PUBLIC_URL . '/' . $avatar;
        }
        $signout_url = WS_PUBLIC_URL . '/admin/sign/out';
        $changepwd_url = WS_PUBLIC_URL . '/admin/user/changepwd';

        $content = <<< endline
<li class="dropdown user user-menu">
    <a href="javascript:void(0);" class="dropdown-toggle" data-toggle="dropdown">
        <img src="{$avatar}" class="user-image">
        <span class="hidden-xs"> {$user->nickname} </span>
    </a>
    <ul class="dropdown-menu">
        <li class="user-header">
            <img src="{$avatar}" class="img-circle" alt="User Image">
            <p>注册时间 <small> {$user->register_time} </small> </p>
        </li>
        <li class="user-body">
            <div class="row">
                <div class="col-xs-4 text-center">
                    <a href="{$changepwd_url}"> 密码修改</a>
                </div>
                <div class="col-xs-4 text-center">
                    <a href="javascript:void(0);">-</a>
                </div>
                <div class="col-xs-4 text-center">
                    <a href="javascript:void(0);">-</a>
                </div>
            </div>
        </li>
        <li class="user-footer">
            <div class="pull-left">
                <a href="javascript:void(0);" class="btn btn-primary btn-flat"> 我的面板 </a>
            </div>
            <div class="pull-right">
                <a href="{$signout_url}" class="btn btn-success btn-flat"> 退出系统 </a>
            </div>
        </li>
    </ul>
</li>
endline;
        return $content;
    }
}

/*
                    <li class="dropdown user user-menu">
                        <!-- Menu Toggle Button -->
                        <a href="javascript:void(0);" class="dropdown-toggle" data-toggle="dropdown">
                            <!-- The user image in the navbar-->
                            <img src="__PUBLIC__/static//img/user2-160x160.jpg" class="user-image" alt="User Image">
                            <!-- hidden-xs hides the username on small devices so only the image appears. -->
                            <span class="hidden-xs">Alexander Pierce</span>
                        </a>
                        <ul class="dropdown-menu">
                            <!-- The user image in the menu -->
                            <li class="user-header">
                                <img src="__PUBLIC__/static//img/user2-160x160.jpg" class="img-circle" alt="User Image">

                                <p>
                                    Alexander Pierce - Web Developer
                                    <small>Member since Nov. 2012</small>
                                </p>
                            </li>
                            <!-- Menu Body -->
                            <li class="user-body">
                                <div class="row">
                                    <div class="col-xs-4 text-center">
                                        <a href="javascript:void(0);">Followers</a>
                                    </div>
                                    <div class="col-xs-4 text-center">
                                        <a href="javascript:void(0);">Sales</a>
                                    </div>
                                    <div class="col-xs-4 text-center">
                                        <a href="javascript:void(0);">Friends</a>
                                    </div>
                                </div>
                                <!-- /.row -->
                            </li>
                            <!-- Menu Footer-->
                            <li class="user-footer">
                                <div class="pull-left">
                                    <a href="javascript:void(0);" class="btn btn-default btn-flat">Profile</a>
                                </div>
                                <div class="pull-right">
                                    <a href="__PUBLIC__/admin/sign/out" class="btn btn-default btn-flat">Sign out</a>
                                </div>
                            </li>
                        </ul>
                    </li>
*/